#include <stdio.h>
int main(void)
{
    FILE *file;                                                                // 统一用一个文件指针操作
    int a[] = {11, 22, 33, 44, 55, 66, 77, 88, 99, 100}, b[10] = {0}, *pb = b; // 修正：初始化pb指向b
    // 修正：用"wb+"模式统一读写，避免"r"和"w"冲突
    file = fopen("data.dat", "wb+");
    if (file == NULL)
    {
        perror("fopen");
        return 1;
    }
    fwrite(a, sizeof(int), 10, file);
    // 修正：写入后调整文件指针到开头再读取
    fseek(file, 0, SEEK_SET);
    fread(pb, sizeof(int), 5, file);
    for (int i = 0; i < 5; i++)
        printf("%d ", pb[i]);
    printf("\n");
    fclose(file);
    return 0;
}